package com.example.huadu_server.house.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.huadu_server.house.entity.HouseImage;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface HouseImageMapper extends BaseMapper<HouseImage> {

    /**
     * 查询指定房源的所有图片
     */
    @Select("SELECT image_url FROM house_images WHERE house_id = #{houseId}")
    List<String> getImagesByHouseId(@Param("houseId") int houseId);

    @Delete("DELETE FROM house_images WHERE house_id = #{houseId}")
    void deleteByHouseId(@Param("houseId") int houseId);
}
